<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class StoreShopRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'name' => ['required'],
            'price' => ['required', 'regex:/^\d+(\.\d{1,2})?$/'], // 整数或保留两位小数
            'stock_quantity' => ['required', 'integer', 'min:0'], // 正整数
            'shop_cate_id' => ['required'],
            'status' => ['required'],
            'url' => ['required'],
            'norm_id' => ['required'],
            // 'urls' => ['required', 'array', 'min:1', 'array'], // 字符串数组
            // 'urls.*' => ['required', 'string'] // 字符串数组
        ];
    }
}
